import {Dept} from "../sql/domin";
import {arrayToMap, deleteSql, insertSql, objectToMap, selectSql, updateSql} from "../util/sqlUtils";

export class DeptMapper{

    public static insertDept(depts:Dept[]){
        return insertSql('sys_dept',arrayToMap(depts))
    }

    public static selectDept(){
        return selectSql('sys_dept')
    }

    public static deleteDept(){
        return deleteSql('sys_dept',"where 1=1")
    }

    public static updateDept(depts:Dept[]){
        depts.forEach(async it=>{
            await updateSql('sys_dept',objectToMap(it),'where deptId = '+it.deptId)
        })
    }

}
